import { createHashRouter } from "react-router-dom";
import Layout from "../pages/layout";
import Login from "../pages/login";
import Home from "../pages/Home";
import Article from "../pages/Article";
import Publish from "../pages/Publish";
import { AuthRoute } from "@/components/AuthRoute.js"



const router = createHashRouter([
  {
    path: "/",
    element: <AuthRoute> <Layout /></AuthRoute>,//插槽方式传递组件 判断是否有token 若无token跳转登录页
    children: [
      {
        path: "home",
        element: <Home />
      },
      {
        path: "article",
        element: <Article />
      },
      {
        path: "publish",
        element: <Publish />
      }
    ]
  },
  {
    path: "/login",
    element: <Login />,
  },
]);

export default router;